<script lang="ts" setup>
import { useStore } from "vuex";
import { useRouter } from "vue-router";
const router = useRouter();
const store = useStore();
import { defineProps } from "vue";
// 定义props的类型
const { item } = defineProps({
  item: {
    type: Object,
    required: true, //必须传值
    default: "",
  },
  // 其他props定义...
});
</script>
<template>
  <div class="grid-content">
    <div class="img-box">
      <img
        :src="`http://localhost:3000/${JSON.parse(item.imageList)[0]}`"
        alt="图片加载异常"
        class="img"
      />
    </div>
    <div class="box-bottom">
      <slot></slot>
      <div class="myData">
        <el-avatar
          @click="router.push(`/personal/${item.username}`)"
          :src="
            item.avatar
              ? `http://localhost:3000${item.avatar}`
              : `http://localhost:3000${store.state.userInfo.avatar}`
          "
          :size="25"
        />
        <span>{{ item.name ? item.name : store.state.userInfo.name }}</span>
      </div>
      <div class="box-content" v-html="item.content"></div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.myData {
  display: flex;
  align-items: center;
  font-size: 8px;
  padding: 5px 0 5px 5px;
  span {
    font-size: 11px;
    padding-left: 7px;
    font-weight: 500;
    color: gray;
  }
}
.grid-content:hover {
  filter: brightness(70%);
}
.grid-content {
  transition: filter 0.3s ease;
  box-sizing: border-box;
  overflow: hidden;
  margin-bottom: 10px;
  font-weight: 600;
  .img-box {
    border-radius: 15px;
    overflow: hidden;
    .img {
      width: 100%;
      display: block;
      margin: 0;
      background-size: cover;
      max-height: 480px;
    }
  }
  .box-bottom {
    padding-left: 5px;
  }
  .box-content {
    width: 100%;
    height: 20px;
    line-height: 20px;

    font-size: 14px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}
</style>
